package com.example.blog.web.dao;

import com.example.blog.web.dataobject.WangruqingBlog;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface WangruqingBlogMapper {
    @Delete({
        "delete from wangruqing_blog",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into wangruqing_blog (id, gmt_created, ",
        "gmt_modified, title, ",
        "userid, words_number, ",
        "pageview, collect_number, ",
        "like_number, comment_number, ",
        "top, original, label, ",
        "recommend, main_body)",
        "values (#{id,jdbcType=BIGINT}, now() ",
        "now(), #{title,jdbcType=VARCHAR}, ",
        "#{userid,jdbcType=BIGINT}, #{wordsNumber,jdbcType=INTEGER}, ",
        "#{pageview,jdbcType=INTEGER}, #{collectNumber,jdbcType=INTEGER}, ",
        "#{likeNumber,jdbcType=INTEGER}, #{commentNumber,jdbcType=INTEGER}, ",
        "#{top,jdbcType=INTEGER}, #{original,jdbcType=INTEGER}, #{label,jdbcType=VARCHAR}, ",
        "#{recommend,jdbcType=INTEGER}, #{mainBody,jdbcType=LONGVARCHAR})"
    })
    int insert(WangruqingBlog record);

    @Select({
        "select",
        "id, gmt_created, gmt_modified, title, userid, words_number, pageview, collect_number, ",
        "like_number, comment_number, top, original, label, recommend, main_body",
        "from wangruqing_blog",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="userid", property="userid", jdbcType=JdbcType.BIGINT),
        @Result(column="words_number", property="wordsNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="pageview", property="pageview", jdbcType=JdbcType.INTEGER),
        @Result(column="collect_number", property="collectNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="like_number", property="likeNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="comment_number", property="commentNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="top", property="top", jdbcType=JdbcType.INTEGER),
        @Result(column="original", property="original", jdbcType=JdbcType.INTEGER),
        @Result(column="label", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="recommend", property="recommend", jdbcType=JdbcType.INTEGER),
        @Result(column="main_body", property="mainBody", jdbcType=JdbcType.LONGVARCHAR)
    })
    WangruqingBlog selectByPrimaryKey(Long id);

    @Select({
        "select",
        "id, gmt_created, gmt_modified, title, userid, words_number, pageview, collect_number, ",
        "like_number, comment_number, top, original, label, recommend, main_body",
        "from wangruqing_blog"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="userid", property="userid", jdbcType=JdbcType.BIGINT),
        @Result(column="words_number", property="wordsNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="pageview", property="pageview", jdbcType=JdbcType.INTEGER),
        @Result(column="collect_number", property="collectNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="like_number", property="likeNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="comment_number", property="commentNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="top", property="top", jdbcType=JdbcType.INTEGER),
        @Result(column="original", property="original", jdbcType=JdbcType.INTEGER),
        @Result(column="label", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="recommend", property="recommend", jdbcType=JdbcType.INTEGER),
        @Result(column="main_body", property="mainBody", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<WangruqingBlog> selectAll();

    @Update({
        "update wangruqing_blog",
        "set ",
          "gmt_modified = now(),",
          "title = #{title,jdbcType=VARCHAR},",
          "userid = #{userid,jdbcType=BIGINT},",
          "words_number = #{wordsNumber,jdbcType=INTEGER},",
          "pageview = #{pageview,jdbcType=INTEGER},",
          "collect_number = #{collectNumber,jdbcType=INTEGER},",
          "like_number = #{likeNumber,jdbcType=INTEGER},",
          "comment_number = #{commentNumber,jdbcType=INTEGER},",
          "top = #{top,jdbcType=INTEGER},",
          "original = #{original,jdbcType=INTEGER},",
          "label = #{label,jdbcType=VARCHAR},",
          "recommend = #{recommend,jdbcType=INTEGER},",
          "main_body = #{mainBody,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(WangruqingBlog record);
}